home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / wrb100c2.zip / MIDNIGHT.BAT < prev    next >
DOS Batch File  |  1993-01-18  |  5KB  |  110 lines

  1. @ECHO OFF
  2. REM
  3. REM      This batch file is OPTIONAL and its use is not required for 
  4. REM      WR-BBS operation.  If this file exists in the WR-BBS home path,
  5. REM      it will be executed each time the computer's date changes. This
  6. REM      is usually once a day, at midnight.  If there is a caller on line
  7. REM      or some other WR-BBS activity occuring when the date changes,
  8. REM      then WR-BBS runs MIDNIGHT.BAT as soon as WR-BBS becomes idle after
  9. REM      the date changes.     
  10. REM
  11. REM      You can modify this batch file to suit you needs.  You do NOT have
  12. REM      to use any of the routines or lines contained in this file.
  13. REM
  14. REM      If you wish to design your own MIDNIGHT.BAT, please keep the
  15. REM      following in mind:
  16. REM
  17. REM      1. WR-BBS passes a six character string to MIDNIGHT.BAT when it
  18. REM         calls the batch file.  This string is the date, in the format
  19. REM         MMDDYY.  You can capture that information by using the DOS
  20. REM         replaceable paramater symbol %1 in MIDNIGHT.BAT.
  21. REM
  22. REM      2. WR-BBS is "shelled" when it calls MIDNIGHT.BAT.  Do not restart
  23. REM         WR-BBS with WR or WRBBS, or you will have two copies of WR-BBS
  24. REM         fighting each other.  Just let the batch file end normally, and
  25. REM         WR-BBS will "unshell" and resume operation.  Since WR-BBS is
  26. REM         still loaded (although swapped out) when MIDNIGHT.BAT executes,
  27. REM         don't load any TSR's, and don't activate any TSR's (such as 
  28. REM         flushing a cache) inside MIDNIGHT.BAT.
  29. REM
  30. REM      3. Never modify or delete any WR-BBS files that end with .DAT or
  31. REM         .IDX inside MIDNIGHT.BAT.  If you want to run a utility that
  32. REM         modifies the data files, you should do it in a "terminate"
  33. REM         event.
  34. REM
  35. REM      4. It is not necessary to reboot the system on a regular basis,
  36. REM         which is a convention that some SysOps are used to following.
  37. REM         If you want to reboot automatically (not necessary), you should
  38. REM         do this in a "terminate" event.
  39. REM
  40. REM
  41. ECHO.
  42. ECHO.
  43. ECHO ████████████████████████████████████████████████████████████
  44. ECHO ██ ┌────────────────┬───────────────────────────────────┐ ██
  45. ECHO ██ │  MIDNIGHT.BAT  │  A utility batch file for WR-BBS  │ ██
  46. ECHO ██ ├────────────────┴───────────────────────────────────┤ ██
  47. ECHO ██ │  Database files are being automatically backed up  │ ██
  48. ECHO ██ └────────────────────────────────────────────────────┘ ██
  49. ECHO ████████████████████████████████████████████████████████████
  50. ECHO.
  51. ECHO.
  52. REM      The following line checks for the existance of the WR-BBS environment
  53. REM      variable.  If that DOS environment variable does not exist,  no other
  54. REM      processing can occur.
  55. REM
  56. IF W%WR-BBS%W==WW GOTO ERROR01
  57. REM
  58. REM      Since the home directory for WR-BBS is known (from the environment
  59. REM      variable), the batch file assures that the correct working directory
  60. REM      is current by changing to the home path directory.
  61. REM
  62. CHDIR %WR-BBS%
  63. REM
  64. REM      Since the home path is the current directory, and the database files 
  65. REM      are closed, the batch file copies the database files to new files
  66. REM      ending in *.DBK.  This creates an identical copy of the database
  67. REM      which can be later copied by this batch file, and other utility,
  68. REM      or manually by the SysOp.  Since open files cannot be copied, this
  69. REM      is one of the only opportunities to create a backup of the database
  70. REM      for later use.
  71. REM
  72. COPY *.DAT *.DBK /V > NUL
  73. REM
  74. REM      The next line looks for a directory named WRBACKUP, which is a 
  75. REM      subdirectory off the home path directory. It tests for the existence
  76. REM      of NUL in that directory.  NUL will exist in any sub-directory
  77. REM      (at least with PC-DOS or MS-DOS), indicating that the directory
  78. REM      already exists. If the directory does not exist, it is created.
  79. REM
  80. IF NOT EXIST %WR-BBS%\WRBACKUP\NUL MKDIR %WR-BBS%\WRBACKUP
  81. REM
  82. REM      The current log file (WRBBSLOG.TXT) is now copied to the backup
  83. REM      directory.  It is renamed during the copy process to a filename 
  84. REM      that reflects the date, for example AL063094.LOG.  This is done by
  85. REM      using the value passed by WR-BBS for the %1 replacable parameter.
  86. REM      WR-BBS passes the date as a six-character string - MMDDYY.
  87. REM
  88. COPY %WR-BBS%\WRBBSLOG.TXT %WR-BBS%\WRBACKUP\AL%1.LOG /V > NUL
  89. REM
  90. REM      The next line checks for the existence of the newly copied and
  91. REM      renamed log file in the WRBACKUP directory.  If the file exists
  92. REM      (which it should), then the copy operation was successful, and 
  93. REM      the original log file can be deleted from its original location
  94. REM      in the home path directory.  WR-BBS will automatically create a
  95. REM      new log file when it discovers the old one is erased.
  96. REM
  97. IF EXIST %WR-BBS%\WRBACKUP\AL%1.LOG DEL %WR-BBS%\WRBBSLOG.TXT
  98. REM
  99. REM      End of processing.  You can add your own routines here, etc.
  100. REM
  101. GOTO FINISHED
  102. :ERROR01
  103. REM
  104. REM      Control is passed to this label if the environment variable
  105. REM      "WR-BBS" is not found.
  106. REM
  107. ECHO ERROR:  Environment variable "WR-BBS" not defined.
  108. :FINISHED
  109. ECHO.
  110.